<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //修改length长度
        var arr = ['red', 'green', 'blue'];
        arr.length = 5;
        console.log(arr);
        console.log(arr[3]);//undefined

        //直接修改索引号
        var arr1 = ['red', 'green', 'blue'];
        arr1[3] = 'pink';
        console.log(arr1);
        arr1[0] = 'yellow';
        console.log(arr1);

        arr1 = '不要直接给数组名赋值';
        console.log(arr1);

        var arr2 = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];
        var arr3 = [];
        var index = 0;
        for (var i = 0; i < arr2.length; i++) {
            if (arr2[i] >= 10) {
                arr3[index] = arr2[i];
                index++;
            }
        }
        console.log(arr3);

        var arr2 = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];
        var arr3 = [];
        for (var i = 0; i < arr2.length; i++) {
            if (arr2[i] >= 10) {
                arr3[arr3.length] = arr2[i];
            }
        }
        console.log(arr3);

    </script>
</head>

<body>

</body>

</html>